Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update environment variables to use javascript-based config #249

Merged
merged 6 commits into from
Dec 4, 2023

Conversation

jsnwesson
Copy link
Contributor

@jsnwesson jsnwesson commented Nov 29, 2023

Context:
In order to use Frontend Plugin Framework Library, every Host MFE needs to use a javascript-based configuration. Most of the groundwork was done in frontend-platform and frontend-build to allow for js-based configs to be used in MFEs, and Learner Dashboard will be the first to make this transformation.

In place of the .env.* files would be a env.config.js file that includes all of the variables that would have existed in .env.development. An example.env.config.js has been added and can be copied.

When a team or developer makes the switch from .env.* to env.config.js, any env vars needed for testing with Jest Snapshot will need to be included in src/setupTest.jsx.

Note: the .env.* files are not being deleted and a future date/announcement will be made when the master branch of Learner Dashboard no longer provides a .env file.

Copy link

codecov bot commented Nov 29, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a4f14da) 96.36% compared to head (edc4afe) 96.36%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #249   +/-   ##
=======================================
  Coverage   96.36%   96.36%           
=======================================
  Files         194      194           
  Lines        1841     1841           
  Branches      324      324           
=======================================
  Hits         1774     1774           
  Misses         62       62           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jsnwesson jsnwesson force-pushed the jwesson/update-to-jsbased-config branch from 3c9e525 to dfbdb59 Compare November 29, 2023 22:44
jest.config.js Outdated Show resolved Hide resolved
@jsnwesson jsnwesson force-pushed the jwesson/update-to-jsbased-config branch from 779f0a4 to 2ba72d9 Compare November 30, 2023 22:23
@jsnwesson jsnwesson force-pushed the jwesson/update-to-jsbased-config branch from 2ba72d9 to f041d35 Compare November 30, 2023 22:25
@jsnwesson jsnwesson force-pushed the jwesson/update-to-jsbased-config branch from 562e24a to ec4e9e8 Compare November 30, 2023 22:54
/*
When .env.test is removed, uncomment the env vars below and add any environment variables for testing with Jest

Context: Snapshot is not currently not set up to be able to parse the environment variables in env.config.js
Copy link
Member

@MaxFrank13 MaxFrank13 Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Context: Snapshot is not currently not set up to be able to parse the environment variables in env.config.js
Context: Snapshot is not currently set up to be able to parse the environment variables in env.config.js

The word "not" is repeated to make this a double negative

Comment on lines +2 to +17
Learner Dashboard is now able to handle JS-based configuration!

For the time being, the `.env.*` files are still made available when cloning down this repo or pulling from
the master branch. To switch to using `env.config.js`, make a copy of `example.env.config.js` and configure as needed.

For testing with Jest Snapshot, there is a mock in `/src/setupTest.jsx` for `getConfig` that will need to be
uncommented.

Note: having both .env and env.config.js files will follow a predictable order, in which non-empty values in the
JS-based config will overwrite the .env environment variables.

frontend-platform's getConfig loads configuration in the following sequence:
- .env file config
- optional handlers (commonly used to merge MFE-specific config in via additional process.env variables)
- env.config.js file config
- runtime config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌 Thank you for adding this valuable context

@jsnwesson jsnwesson merged commit bd0c0c5 into master Dec 4, 2023
6 checks passed
@jsnwesson jsnwesson deleted the jwesson/update-to-jsbased-config branch December 4, 2023 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants